/*
 * @# FanRedis.java 2011-12-24 下午02:52:30
 * 
 * Copyright (C) 2010 - 2011 广州羿安信息科技有限公司
 * Guangzhou ianswer information technology co. ltd.
 * 
 * All rights reserved!
 */
package com.ianswer.px.user.redis;

import java.util.List;

import com.ianswer.px.common.redis.RedisSupport;

/**
 * 粉丝列表.
 * 
 * @author alvin hwang
 */
public class FanRedis extends RedisSupport {

	private static final String FOLLOW_PREFIX = "fan:";

	public static boolean add(Long who, Long whom, Long addtime) {
		return settedIfExists(redis().lpush(key(whom), String.valueOf(who)));
	}

	public static boolean remove(Long who, Long whom) {
		return delSuccess(redis().lrem(key(whom), 0, String.valueOf(who)));
	}

	public static List<String> getFans(Long userId, int start, int end) {
		return redis().lrange(key(userId), start, end);
	}

	private static String key(Long userId) {
		return FOLLOW_PREFIX + userId;
	}

}
